package com.cjl.demo.juc;

import jdk.nashorn.internal.objects.annotations.Setter;

import java.util.concurrent.atomic.AtomicReference;

/**
 * <p>Copyright: All Rights Reserved</p>
 * <p>Description: </p>
 *
 * @ uthor chenjinliang
 * @ date: 2020/2/16
 */
public class AtomicReferenceDemo {
    public static void main(String[] args) {
        User zs = new User("zs", 22);
        User ls = new User("ls", 22);
        AtomicReference<User> userAtomicReference = new AtomicReference<>();
        userAtomicReference.set(zs);
        System.out.println(userAtomicReference.compareAndSet(zs, ls) + "\t" + userAtomicReference.get().toString());
        System.out.println(userAtomicReference.compareAndSet(zs, ls) + "\t" + userAtomicReference.get().toString());
    }
}


